/*
 * Communication.h
 *
 *  Created on: Aug 27, 2011
 *      Author: ryan
 */

#ifndef COMMUNICATION_H_
#define COMMUNICATION_H_

#include "mpi.h"

class Communication {
public:
	Communication(int tr, int pr, int ne){
		taskRANK = tr;
		pre = pr;
		next = ne;
	}

	static int RANK, SIZE;
	static void initialize(int argc, char *argv[]);
	static void finalize();
	static void sendTo(void* p, int size, int dst);
	static void recvFrom(void *p, int size, int src);
	void sendToNext(void* p, int size);
	void sendToPre(void* p, int size);
	void recvFromNext(void* p, int size);
	void recvFromPre(void* p, int size);

private:
	int taskRANK, pre, next;
	static bool hasInitlized;
	static MPI_Request request;
	static MPI_Status status;
	static bool mpiCheck();
};

#endif /* COMMUNICATION_H_ */
